package com.ruoyi.assignments.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.assignments.domain.ExpertAssignments;
import com.ruoyi.assignments.service.IExpertAssignmentsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专家分配中间表Controller
 * 
 * @author ruoyi
 * @date 2025-04-24
 */
@RestController
@RequestMapping("/专家分配中间表/assignments")
public class ExpertAssignmentsController extends BaseController
{
    @Autowired
    private IExpertAssignmentsService expertAssignmentsService;

    /**
     * 查询专家分配中间表列表
     */
    @PreAuthorize("@ss.hasPermi('专家分配中间表:assignments:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExpertAssignments expertAssignments)
    {
        startPage();
        List<ExpertAssignments> list = expertAssignmentsService.selectExpertAssignmentsList(expertAssignments);
        return getDataTable(list);
    }

    /**
     * 导出专家分配中间表列表
     */
    @PreAuthorize("@ss.hasPermi('专家分配中间表:assignments:export')")
    @Log(title = "专家分配中间表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExpertAssignments expertAssignments)
    {
        List<ExpertAssignments> list = expertAssignmentsService.selectExpertAssignmentsList(expertAssignments);
        ExcelUtil<ExpertAssignments> util = new ExcelUtil<ExpertAssignments>(ExpertAssignments.class);
        util.exportExcel(response, list, "专家分配中间表数据");
    }

    /**
     * 获取专家分配中间表详细信息
     */
    @PreAuthorize("@ss.hasPermi('专家分配中间表:assignments:query')")
    @GetMapping(value = "/{assignmentId}")
    public AjaxResult getInfo(@PathVariable("assignmentId") Long assignmentId)
    {
        return success(expertAssignmentsService.selectExpertAssignmentsByAssignmentId(assignmentId));
    }

    /**
     * 新增专家分配中间表
     */
    @PreAuthorize("@ss.hasPermi('专家分配中间表:assignments:add')")
    @Log(title = "专家分配中间表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExpertAssignments expertAssignments)
    {
        return toAjax(expertAssignmentsService.insertExpertAssignments(expertAssignments));
    }

    /**
     * 修改专家分配中间表
     */
    @PreAuthorize("@ss.hasPermi('专家分配中间表:assignments:edit')")
    @Log(title = "专家分配中间表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExpertAssignments expertAssignments)
    {
        return toAjax(expertAssignmentsService.updateExpertAssignments(expertAssignments));
    }

    /**
     * 删除专家分配中间表
     */
    @PreAuthorize("@ss.hasPermi('专家分配中间表:assignments:remove')")
    @Log(title = "专家分配中间表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assignmentIds}")
    public AjaxResult remove(@PathVariable Long[] assignmentIds)
    {
        return toAjax(expertAssignmentsService.deleteExpertAssignmentsByAssignmentIds(assignmentIds));
    }
}
